package cn.gov.pbc.audit.vo;

import com.alibaba.excel.annotation.ExcelProperty;

import cn.gov.pbc.audit.common.LoanConst;
import cn.gov.pbc.audit.dao.InstitutionMapper;
import cn.gov.pbc.audit.pojo.Loan;
import cn.gov.pbc.audit.util.DateTimeUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class LoanItemVo {
	@ExcelProperty(value = "序号")
	private Integer id;
	
	@ExcelProperty(value = "机构")
	private String institutionName;

	@ExcelProperty(value = "金融机构名称")
    private String orgName;

	@ExcelProperty(value = "金融机构编码")
    private String orgCode;

	@ExcelProperty(value = "客户编号")
    private String clientCode;

	@ExcelProperty(value = "客户名称")
    private String clientName;

	@ExcelProperty(value = "客户联系方式")
    private String clientNo;

	@ExcelProperty(value = "客户类别")
    private String clientType;

	@ExcelProperty(value = "客户证件号码")
    private String clientId;

	@ExcelProperty(value = "贷款发放金额（万元）")
    private String loan;

	@ExcelProperty(value = "贷款余额（万元）")
    private String loanBalance;

	@ExcelProperty(value = "贷款利率（%）")
    private String interestRate;

	@ExcelProperty(value = "贷款发放日")
    private String loanStartDay;

	@ExcelProperty(value = "贷款到期日")
    private String loanEndDay;

	@ExcelProperty(value = "贷款划型")
    private String loanType;

	@ExcelProperty(value = "贷款划型细项")
    private String loanTypeDetail;

	@ExcelProperty(value = "贷款用途")
    private String loanUse;
	
	@ExcelProperty(value = "贷款质量")
    private String loanStatus;

	@ExcelProperty(value = "贷款贴息及补偿方式")
    private String loanCompensate;

	@ExcelProperty(value = "担保方式")
    private String guaranteeType;

	@ExcelProperty(value = "担保人")
    private String bail;

	@ExcelProperty(value = "抵质押物种类")
    private String pledgeType;

	@ExcelProperty(value = "外部增信方式")
    private String externalCreditEnhancement;

	@ExcelProperty(value = "备注")
    private String note;
	
	public void assmbleFromLoad(Loan loan, Integer index, InstitutionMapper institutionMapper) {
		this.setId(index);
		this.setInstitutionName(institutionMapper.selectByPrimaryKey(loan.getInstitutionId()).getName());
	    this.setOrgName(loan.getOrgName());
	    this.setOrgCode(loan.getOrgCode());
	    this.setClientCode(loan.getClientCode());
	    this.setClientName(loan.getClientName());
	    this.setClientNo(loan.getClientNo());
	    this.setClientType(LoanConst.ClientType.codeOf(loan.getClientType()).getValue());
	    this.setClientId(loan.getClientId());
	    this.setLoan(loan.getLoan().toString());
	    this.setLoanBalance(loan.getLoanBalance().toString());
	    this.setInterestRate(loan.getInterestRate().toString());
	    this.setLoanStartDay(DateTimeUtil.dateOnlyToStr(loan.getLoanStartDay()));
	    this.setLoanEndDay(DateTimeUtil.dateOnlyToStr(loan.getLoanEndDay()));
	    this.setLoanType(loan.getLoanType());
	    this.setLoanTypeDetail(loan.getLoanTypeDetail());
	    this.setLoanUse(loan.getLoanUse());
	    this.setLoanStatus(LoanConst.LoanStatus.codeOf(loan.getLoanStatus()).getValue());
	    this.setLoanCompensate(loan.getLoanCompensate());
	    this.setGuaranteeType(loan.getGuaranteeType());
	    this.setBail(loan.getBail());
	    this.setPledgeType(loan.getPledgeType());
	    this.setExternalCreditEnhancement(loan.getExternalCreditEnhancement());
	    this.setNote(loan.getNote());
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
}
